<!-- 我的 -->
<template>
  <div class="app-container">
    <div class="header">
      <div class="left">
        <span>我的</span>
      </div>
      <div class="right">
        <el-button type="text" icon="el-icon-more"></el-button>
        <el-button type="text" icon="el-icon-s-help"></el-button>
      </div>
    </div>
    <div class="user-info">
      <img :src="user.photo" style="width: 65px; height: 65px; border-radius: 50%">
      <span class="user-name" v-if="user!=''">{{user.nickName}}</span>
      <span class="user-name" v-if="token==null" @click="login">请登录</span>
    </div>
    <div class="menu">
      <div class="menu-item" @click="announce">
        <el-button icon="el-icon-s-operation"></el-button>
        <span>我的发布</span>
      </div>
      <div class="menu-item" @click="collect">
        <el-button icon="el-icon-star-off"></el-button>
        <span>我的收藏</span>
      </div>
      <div class="menu-item" @click="history">
        <el-button icon="el-icon-view"></el-button>
        <span>浏览记录</span>
      </div>
      <div class="menu-item" @click="contact">
        <el-button icon="el-icon-cpu"></el-button>
        <span>AI助手</span>
      </div>
      <div class="menu-item" @click="agreement">
        <el-button icon="el-icon-document"></el-button>
        <span>服务协议</span>
      </div>
      <div class="menu-item" @click="us">
        <el-button icon="el-icon-info"></el-button>
        <span>关于我们</span>
      </div>
      <div class="menu-item" style="margin-right: 265px" @click="settings">
        <el-button icon="el-icon-setting"></el-button>
        <span>设置</span>
      </div>
    </div>
    <div class="footer">
      <div class="footer-item" @click="indexRental">
        <el-button icon="el-icon-s-home"></el-button>
        <span>首页</span>
      </div>
      <div class="footer-item" @click="release">
        <el-button icon="el-icon-circle-plus-outline"></el-button>
        <span>发布</span>
      </div>
      <div class="footer-item" @click="accelerate">
        <el-button icon="el-icon-orange"></el-button>
        <span>加速器</span>
      </div>
      <div class="footer-item active" style="color: #F4A780;">
        <el-button icon="el-icon-user"></el-button>
        <span>我的</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      user:{},
      token: '',
    };
  },
  methods: {
    release(){
      this.$router.push('/release')
    },
    indexRental(){
      this.$router.push('/')
    },
    accelerate(){
      this.$router.push('/accelerate')
    },
    login(){
      this.$router.push('/')
    },
    us(){
      this.$router.push('/us')
    },
    agreement(){
      this.$router.push('/agreement')
    },
    settings(){
      this.$router.push({path: '/settings', query: {id: JSON.stringify(this.user.id)}})
    },
    contact(){
      this.$router.push('/contact')
    },
    history(){
      this.$router.push('/history')
    },
    collect(){
      this.$router.push('/collect')
    },
    announce(){
      this.$router.push({path: '/announce', query: {id: JSON.stringify(this.user.id)}})
    },
    getUserInfo(){
      this.axios.get('http://localhost:9701/web/userInfo/getUserInfo').then(res => {
        if (res.data.code === 200) {
          this.user = res.data.data;
        }
      })
    }
  },
  created() {
    this.token = localStorage.getItem('token')
    this.getUserInfo();
  }
}
</script>

<style scoped>
.app-container {
  width: 390px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  margin: 0 auto;
}



.left {
  color: #F4A780;
  font-size: 18px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.right {
  display: flex;
  border: 1px solid #F4A780;
  padding: 5px 5px;
  border-radius: 15px;
}

.right button {
  color: #F4A780;
  padding: 0 5px;
  font-size: 18px;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 20px;
  padding-bottom: 30px;
  border-bottom: 1px dashed #eee;
}

.user-info img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
}

.user-name {
  margin-top: 10px;
  color: #F4A780;
  font-size: 16px;
}

.menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  margin-top: 30px;
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 30px;
  width: 30%;
}

.menu-item button{
  color: #F4A780;
  font-size: 25px;
  border: none;
  background-color: transparent;
}

.footer {
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid #eee;
  position: fixed;
  bottom: 0;
  width: 390px;
  background-color: #fff;
}

.footer-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
}

.footer-item button {
  font-size: 25px;
  border: none;
  background-color: transparent;
  color: unset;
}
</style>